<?php

Solar::loadClass('Solar_Base');

class Domain51_Service_Amazon_Util_Connection_Response extends Solar_Base
{
    protected $_Domain51_Service_Amazon_Util_Connection_Response = array(
        'connection_type' => 'pecl'
    );
    
    private $_validTypes = array('pecl', 'zend', 'pear');
    
    private $_resposne = null;
    
    public function __construct($config = null)
    {
        parent::__construct($config);
        if (!in_array($this->_config['connection_type'], $this->_validTypes)) {
            throw $this->_exception(
                'ERR_INVALID_CONFIG_VALUE',
                array('connection_type' => $this->_config['connection_type'])
            );
        }
        
        $this->_response = $config['response'];
    }
    
    
    public function getResponseCode() 
    {
        switch ($this->_config['connection_type']) {
        case 'pecl' :
            return $this->_response->responseCode;
            break;
        case 'zend' :
            return $this->_response->getStatus();
            break;
        case 'pear' :
            return $this->_response->getResponseCode();
            break;
        }
    }
    
    public function getBody()
    {
        switch ($this->_config['connection_type']) {
        case 'pecl' :
            return $this->_response->body;
            break;
        case 'zend' :
            return $this->_response->getBody();
            break;
        case 'pear' :
            return $this->_response->getResponseBody();
            break;
        }
    }
    
    public function getHeaders()
    {
        switch ($this->_config['connection_type']) {
        case 'pecl' :
            return $this->_response->headers;
            break;
        case 'zend' :
            return $this->_response->getHeaders();
            break;
        case 'pear' :
            return $this->_response->getResponseHeaders();
            break;
        }
    }
}

?>